'use strict';

import Base from './base.js';

export default class extends Base {
	loginAction(ctrl) {
		return ctrl.display();
	}

	async signinAction(ctrl) {
		if (ctrl.isGet()) {
			return ctrl.redirect('/user/login');
		}
		//let res = await httpTokenPost('http://dashudongcha.51vip.biz:8085/dsdc-ws/system/login', {
		//	username: ctrl.post('username'),
		//	password: ctrl.post('password')
		//}, ctrl, false);
		//if (res && res.code == 200) {
			//await ctrl.session('userInfo', res.result);
			return ctrl.redirect('/index/index');
		//}
		//ctrl.assign('error', res);
		//ctrl.assign('username', ctrl.post('username'));
		//return ctrl.display('login');
	}

	async logoutAction(ctrl) {
		await ctrl.session();
		return ctrl.redirect('/user/login');
	}

	async menugetAction(ctrl) {
		let userInfo = await ctrl.session('userInfo');
		let token = userInfo.token;
		let res = await httpTokenPost('http://dashudongcha.51vip.biz:8085/dsdc-ws/user/menu/get', {}, ctrl);
		return ctrl.json(res);
	}
}